package com.cinema;
import java.util.Date;
public class Admin extends User {
    public Admin(String userId, String username, String password, Date registerTime, String phone, String userType) {
        super(userId, username, password, registerTime, phone, userType);
    }

    public void changeOwnPassword(String newPassword) {
        String encryptedPwd = MD5Util.encrypt(newPassword);
        super.setPassword(encryptedPwd);
        String log = String.format("[%s] 操作类型：修改管理员密码，操作人：%s", new Date(), super.getUsername());
        DataManager.logList.add(log);
    }

    public void resetUserPassword(User user) {
        if (user instanceof Admin) {
            System.out.println("不能重置管理员密码");
            return;
        }
        String defaultPwd = MD5Util.encrypt("123456");
        user.setPassword(defaultPwd);

        String log = String.format("[%s] 操作类型：重置%s%s的密码，操作人：%s",
                new Date(), user.getUserType(), user.getUsername(), super.getUsername());
        DataManager.logList.add(log);
    }
}
